/*    */ package com.feeyin.radar.sys.controller;
/*    */ 
/*    */ import java.io.BufferedOutputStream;
/*    */ import java.io.FileOutputStream;
/*    */ import java.io.PrintStream;
/*    */ import javax.servlet.ServletContext;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import javax.servlet.http.HttpSession;
/*    */ import org.springframework.validation.BindException;
/*    */ import org.springframework.web.bind.ServletRequestDataBinder;
/*    */ import org.springframework.web.multipart.support.ByteArrayMultipartFileEditor;
/*    */ import org.springframework.web.servlet.ModelAndView;
/*    */ import org.springframework.web.servlet.mvc.SimpleFormController;
/*    */ import org.springframework.web.servlet.view.RedirectView;
/*    */ 
/*    */ public class UploadController_demo extends SimpleFormController
/*    */ {
/*    */   private String path;
/*    */ 
/*    */   public String getPath()
/*    */   {
/* 21 */     return this.path;
/*    */   }
/*    */ 
/*    */   public void setPath(String path) {
/* 25 */     this.path = path;
/*    */   }
/*    */ 
/*    */   public UploadController_demo() {
/* 29 */     setCommandClass(FileForm.class);
/*    */   }
/*    */ 
/*    */   protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
/*    */     throws Exception
/*    */   {
/* 35 */     FileForm fileForm = (FileForm)command;
/*    */ 
/* 37 */     String contents = request.getParameter("contents");
/*    */ 
/* 40 */     System.out.println("fileForm = " + fileForm.getContents()[0]);
/*    */ 
/* 42 */     System.out.println("fileName = " + fileForm.getFileName());
/*    */ 
/* 46 */     String basePath = request.getSession().getServletContext().getRealPath("/") + "upload";
/*    */ 
/* 48 */     String storedPath = basePath + System.getProperty("file.separator") + "009testTree.doc";
/*    */ 
/* 50 */     System.out.println("storedPath = " + storedPath);
/*    */ 
/* 58 */     BufferedOutputStream bufferedOutputStream = 
/* 59 */       new BufferedOutputStream(
/* 60 */       new FileOutputStream(storedPath));
/*    */ 
/* 62 */     bufferedOutputStream.write(fileForm.getContents());
/*    */ 
/* 64 */     bufferedOutputStream.close();
/*    */ 
/* 66 */     return new ModelAndView(new RedirectView("./user.do?action=preAddUser"));
/*    */   }
/*    */ 
/*    */   protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
/* 70 */     super.initBinder(request, binder);
///* 71 */     binder.registerCustomEditor([B.class, new ByteArrayMultipartFileEditor());
/*    */   }
/*    */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.controller.UploadController_demo
 * JD-Core Version:    0.6.0
 */